home *** CD-ROM | disk | FTP | other *** search
/ MASPC 1 / MASPC_1.iso / Demos / Demo DIV / DATA / DLL / SOURCE / DIV.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-12-03  |  14.6 KB  |  330 lines

  1.  
  2. // ────────────────────────────────────────────────────────────────────────────
  3. // DIV Games Studio - Dinamic Link Library - Header File (c) 1998 HAMMER Tech.
  4. // ────────────────────────────────────────────────────────────────────────────
  5.  
  6. #ifndef __DIV_H_
  7. #define __DIV_H_
  8.  
  9. #include <stdio.h>
  10.  
  11. #ifdef GLOBALS
  12.   #define EXTERN
  13.   void main(){};
  14. #else
  15.   #define EXTERN extern
  16. #endif
  17.  
  18. // ────────────────────────────────────────────────────────────────────────────
  19. // Common definitions for all libraries
  20. // ────────────────────────────────────────────────────────────────────────────
  21.  
  22. #define NULL            0
  23.  
  24. #define long_header     36
  25. #define end_struct      long_header+12+10*10+10*7+8+8
  26.  
  27. #define COMMON_PARAMS   void *(*DIV_import)(char *name),\
  28.                         void (*DIV_export)(char *name,void *obj)
  29. #define LIBRARY_PARAMS  void (*COM_export)(char *name,void *obj,int nparms)
  30.  
  31. #define AutoLoad()      DIV_export("Autoload",divmain)
  32.  
  33. // ────────────────────────────────────────────────────────────────────────────
  34. // Definitions of basic language structures
  35. // ────────────────────────────────────────────────────────────────────────────
  36.  
  37. typedef struct __reserved{
  38.         int     id;            // Process Identifier
  39.         int     idscan;        // Collisions
  40.         int     block;         // Process type
  41.         int     blscan;        // Last getid()
  42.         int     status;        // Actual status
  43.         int     param;         // Pointer to parameters
  44.         int     ip;            // Program counter
  45.         int     executed;      // Is process executed?
  46.         int     painted;       // Is process painted?
  47.         int     dist1;         // 1st. process distance (mode 7)
  48.         int     dist2;         // 2nd. process distance (mode 7)
  49.         int     frame;         // Percent of frame complete
  50.         int     x0,y0,x1,y1;   // Bounding box
  51. }_reserved;
  52.  
  53. typedef struct _process{
  54.         _reserved       reserved;       // See above.
  55.         int             father;         // Father's id
  56.         int             son;            // Son's id
  57.         int             smallbro;       // Small brother's id
  58.         int             bigbro;         // Big brother's id
  59.         int             priority;       // Process priority
  60.         int             ctype;          // Type of coordinates
  61.         int             x;              // X of process
  62.         int             y;              // Y of process
  63.         int             z;              // Z of process
  64.         int             graph;          // Code of process graphic
  65.         int             flags;          // Flags of process
  66.         int             size;           // Size of process
  67.         int             angle;          // Angle of process
  68.         int             region;         // Region of process
  69.         int             file;           // File of process
  70.         int             xgraph;         // Pointer to angular graphic table
  71.         int             height;         // Height of process in mode 7
  72.         int             cnumber;        // Scroll or mode 7 for that process
  73.         int             resolution;     // Coordinates resolution of process
  74. }process;
  75.  
  76. typedef struct __mouse{
  77.         int     x;      // Mouse x
  78.         int     y;      // Mouse y
  79.         int     z;      // Mouse z
  80.         int     file;   // File code for mouse graphic
  81.         int     graph;  // Mouse graphic code
  82.         int     angle;  // Pointer angle
  83.         int     size;   // Pointer size (percent)
  84.         int     flags;  // Mouse flags
  85.         int     region; // Mouse region (clipping)
  86.         int     left;   // Left mouse button
  87.         int     middle; // Middle mouse button
  88.         int     right;  // Right mouse button
  89. }_mouse;
  90.  
  91. typedef struct __scroll{
  92.         int     z;              // Scroll Z
  93.         int     camera;         // Process identifier code
  94.         int     ratio;          // Background speed ratio
  95.         int     speed;          // Maximum scrolling speed
  96.         int     region1;        // First region
  97.         int     region2;        // Second region
  98.         int     x0;             // First map coordinates
  99.         int     y0;
  100.         int     x1;             // Second map coordinates
  101.         int     y1;
  102. }_scroll;
  103.  
  104. typedef struct __m7{
  105.         int     z;              // Mode 7 Z
  106.         int     camera;         // Process identifier code
  107.         int     height;         // Camera height
  108.         int     distance;       // Distance between process and camera
  109.         int     horizon;        // Horizon position
  110.         int     focus;          // Camera focus
  111.         int     color;          // Ground colour
  112. }_m7;
  113.  
  114. typedef struct __joy{
  115.         int     button1;        // Joystick buttons (0/1)
  116.         int     button2;
  117.         int     button3;
  118.         int     button4;
  119.         int     left;           // Joystick moves (0/1)
  120.         int     right;
  121.         int     up;
  122.         int     down;
  123. }_joy;
  124.  
  125. typedef struct __setup{
  126.         int     card;
  127.         int     port;
  128.         int     irq;
  129.         int     dma;
  130.         int     dma2;
  131.         int     master;
  132.         int     sound_fx;
  133.         int     cd_audio;
  134. }_setup;
  135.  
  136. // ────────────────────────────────────────────────────────────────────────────
  137. // Description of some basic DIV archives (for modifying them once loaded)
  138. // ────────────────────────────────────────────────────────────────────────────
  139.  
  140. typedef struct _FPGHEADER{
  141.         char     header[8];
  142.         char     palette[768];
  143.         char     colorbars[16*36];
  144. }FPGHEADER;
  145.  
  146. typedef struct _FPGBODY{
  147.         int      code;
  148.         int      lenght;
  149.         char     description[32];
  150.         char     filename[12];
  151.         int      wide;
  152.         int      height;
  153.         int      number_of_points;
  154.         //short  *points;   // 2*number_of_points
  155.         //char   *graphic;  // wide*height
  156. }FPGBODY;
  157.  
  158. typedef struct _FNTHEADER{
  159.     char    header[7];
  160.     char    eof;
  161. } FNTHEADER;
  162.  
  163. typedef struct _FNTBODY{
  164.     int    wide;
  165.     int    height;
  166.     int    screen_offset;
  167.     int    file_offset;
  168. }FNTBODY;
  169.  
  170. // ────────────────────────────────────────────────────────────────────────────
  171. // DIV standard Entry-Points
  172. // You must define these functions on the DLL if you want DIV32RUN to call them up.
  173. // ────────────────────────────────────────────────────────────────────────────
  174.  
  175. void set_video_mode(void);                  // Set new video mode (wide x height)
  176. void process_palette(void);                 // Modify a new palette
  177. void process_active_palette(void);          // Modify a new active palette (fadings)
  178. void process_sound(char *sound,int lenght); // Modify a new sound effect
  179. void process_fpg(char *fpg,int fpg_lenght); // Modify a new FPG
  180. void process_map(char *map,int map_lenght); // Modify a new MAP
  181. void process_fnt(char *fnt,int fnt_lenght); // Modify a new FNT
  182. void background_to_buffer(void);            // Dump background to buffer
  183. void buffer_to_video(void);                 // Dump buffer to video
  184. void post_process_scroll(void);             // Apply effect on scroll window
  185. void post_process_m7(void);                 // Apply effect on mode 7 window
  186. void post_process_buffer(void);             // Apply effect on buffer (video)
  187. void post_process(void);                    // Modify process variables
  188. void put_sprite(byte * si, int x, int y,    // Put one sprite
  189.      int an, int al, int xg, int yg, int ang, int size, int flags);
  190. void ss_init(void);                         // Screen Saver initialisation function
  191. void ss_frame(void);                        // Screen Saver frame function
  192. void ss_end(void);                          // Screen Saver ending function
  193.  
  194. // ────────────────────────────────────────────────────────────────────────────
  195. // DIV exported (shared) variables
  196. // ────────────────────────────────────────────────────────────────────────────
  197.  
  198. #define mem             (_mem)              // Memory of all programs (mem[], int array)
  199. #define stack           (_stack)            // mem[] index of stack
  200. #define palette         (_palette)          // Pointer to game palette
  201. #define active_palette  (_active_palette)   // Pointer to active palette (fadings)
  202. #define key             (_key)              // Pointer to keycodes table (128 bytes)
  203.  
  204. #define sp              (*_sp)              // Stack pointer (as a mem[] index)
  205. #define wide            (*_wide)            // Screen wide (pixels)
  206. #define height          (*_height)          // Screen height (pixels)
  207. #define ss_time         (*_ss_time)         // ScreenSaver calling (def: 3000 = 30 seconds)
  208. #define ss_status       (*_ss_status)       // ScreenSaver status (0/1-Active)
  209. #define ss_exit         (*_ss_exit)         // Set to 1 to end ScrenSaver (ss_frame())
  210. #define process_size    (*_process_size)    // Size of every process (on mem[], number of ints)
  211. #define id_offset       (*_id_offset)       // mem[] index of last executed process
  212. #define id_init_offset  (*_id_init_offset)  // mem[] index of first process
  213. #define id_start_offset (*_id_start_offset) // mem[] index of main process
  214. #define id_end_offset   (*_id_end_offset)   // mem[] index of last process
  215. #define set_palette     (*_set_palette)     // Set to 1 to activate a new palette,
  216.                                             // set to 2 to activate it twice, etc.
  217.  
  218. #define buffer     ((char*)*((unsigned long *)_buffer))     // Pointer to video buffer
  219. #define background ((char*)*((unsigned long *)_background)) // Pointer to video background
  220. #define ghost      ((char*)*((unsigned long *)_ghost))      // Pointer to ghost-layering table
  221.  
  222. // ────────────────────────────────────────────────────────────────────────────
  223. // DIV exported variables - Internal - You must use above definitions!
  224. // ────────────────────────────────────────────────────────────────────────────
  225.  
  226. EXTERN int  *_stack;
  227. EXTERN int  *_mem;
  228. EXTERN char *_palette;
  229. EXTERN char *_active_palette;
  230. EXTERN char *_key;
  231.  
  232. EXTERN int  *_sp;
  233. EXTERN int  *_wide;
  234. EXTERN int  *_height;
  235. EXTERN int  *_ss_time;
  236. EXTERN int  *_ss_status;
  237. EXTERN int  *_ss_exit;
  238. EXTERN int  *_process_size;
  239. EXTERN int  *_id_offset;
  240. EXTERN int  *_id_init_offset;
  241. EXTERN int  *_id_start_offset;
  242. EXTERN int  *_id_end_offset;
  243. EXTERN int  *_set_palette;
  244.  
  245. EXTERN unsigned long _buffer;
  246. EXTERN unsigned long _background;
  247. EXTERN unsigned long _ghost;
  248.  
  249. // ────────────────────────────────────────────────────────────────────────────
  250. // DIV exported functions
  251. // ────────────────────────────────────────────────────────────────────────────
  252.  
  253. EXTERN void *(*div_malloc)(size_t __size);             // Don't use malloc()!!!
  254. EXTERN void  (*div_free  )( void *__ptr );             // Don't use free()!!!
  255. EXTERN FILE *(*div_fopen )(char *,char *);             // Don't use fopen()!!!
  256. EXTERN void  (*div_fclose)(FILE *);                    // Don't use fclose()!!!
  257.  
  258. EXTERN int   (*div_rand)(int rang_low,int rang_hi);    // Random between two numbers
  259. EXTERN void  (*div_text_out)(char *texto,int x,int y); // Screen print function
  260.  
  261. // ────────────────────────────────────────────────────────────────────────────
  262. // Macros to get parameters and return values in new functions
  263. // ────────────────────────────────────────────────────────────────────────────
  264.  
  265. #define getparm()     stack[sp--]           // Get next parameter
  266. #define retval(_x_sp) (stack[++sp]=(_x_sp)) // Set return value (is a must)
  267.  
  268. // ────────────────────────────────────────────────────────────────────────────
  269. // Games exported variables (see documentation - Language - Global - Variables)
  270. // ────────────────────────────────────────────────────────────────────────────
  271.  
  272. #define timer(x)          mem[end_struct+x]
  273. #define text_z            mem[end_struct+10]
  274. #define fading            mem[end_struct+11]
  275. #define shift_status      mem[end_struct+12]
  276. #define ascii             mem[end_struct+13]
  277. #define scan_code         mem[end_struct+14]
  278. #define joy_filter        mem[end_struct+15]
  279. #define joy_status        mem[end_struct+16]
  280. #define restore_type      mem[end_struct+17]
  281. #define dump_type         mem[end_struct+18]
  282. #define max_process_time  mem[end_struct+19]
  283. #define fps               mem[end_struct+20]
  284.  
  285. #define text_offset       mem[7] // Start of text segment (mem[] index)
  286.  
  287. // ────────────────────────────────────────────────────────────────────────────
  288. // Games exported structures (see documentation - Language - Global - Structures)
  289. // ────────────────────────────────────────────────────────────────────────────
  290.  
  291. #define MOUSE  ((_mouse  *)&mem[long_header])
  292. #define SCROLL ((_scroll *)&mem[long_header+12])
  293. #define M7     ((_m7     *)&mem[long_header+12+10*10])
  294. #define JOY    ((_joy    *)&mem[long_header+12+10*10+10*7])
  295. #define SETUP  ((_setup  *)&mem[long_header+12+10*10+10*7+8])
  296.  
  297. // ────────────────────────────────────────────────────────────────────────────
  298. // Definition to get the offset of objects
  299. // ────────────────────────────────────────────────────────────────────────────
  300.  
  301. #define GLOBAL_IMPORT()                                       \
  302. stack            =(int *)DIV_import("stack");                 \
  303. mem              =(int *)DIV_import("mem");                   \
  304. palette          =(char*)DIV_import("palette");               \
  305. active_palette   =(char*)DIV_import("active_palette");        \
  306. key              =(char*)DIV_import("key");                   \
  307. _buffer          =(unsigned long)DIV_import("buffer");        \
  308. _background      =(unsigned long)DIV_import("background");    \
  309. _ghost           =(unsigned long)DIV_import("ghost");         \
  310. _sp              =(int *)DIV_import("sp");                    \
  311. _wide            =(int *)DIV_import("wide");                  \
  312. _height          =(int *)DIV_import("height");                \
  313. _ss_time         =(int *)DIV_import("ss_time");               \
  314. _ss_status       =(int *)DIV_import("ss_status");             \
  315. _ss_exit         =(int *)DIV_import("ss_exit");               \
  316. _process_size    =(int *)DIV_import("process_size");          \
  317. _id_offset       =(int *)DIV_import("id_offset");             \
  318. _id_init_offset  =(int *)DIV_import("id_init_offset");        \
  319. _id_start_offset =(int *)DIV_import("id_start_offset");       \
  320. _id_end_offset   =(int *)DIV_import("id_end_offset");         \
  321. _set_palette     =(int *)DIV_import("set_palette");           \
  322. div_malloc  = ( void *(*)(size_t )       ) DIV_import("div_malloc"); \
  323. div_free    = ( void  (*)(void * )       ) DIV_import("div_free"  ); \
  324. div_fopen   = ( FILE *(*)(char *,char *) ) DIV_import("div_fopen" ); \
  325. div_fclose  = ( void  (*)(FILE *)        ) DIV_import("div_fclose"); \
  326. div_rand    = ( int   (*)(int ,int )     ) DIV_import("div_rand"  ); \
  327. div_text_out= ( void  (*)(char *,int,int)) DIV_import("div_text_out");
  328.  
  329. #endif
  330.